package com.liugege.make.singleton;
/**
* @author: LiuGeGe
* @Date: 2022/3/2 15:46
* @Description(类描述):  饿汉式  单例设计模式  线程安全
* @Class(类): SingletonDemo1
*/
public class SingletonDemo1 {
    private static  final SingletonDemo1 singleton = new SingletonDemo1();
    private  SingletonDemo1() {
        System.out.println("单例模式--饿汉");
    }
    public  static  SingletonDemo1 getInstance(){
        return  singleton;
    }

    public static void main(String[] args) {
        SingletonDemo1 instance1 = SingletonDemo1.getInstance();
        SingletonDemo1 instance2 = SingletonDemo1.getInstance();
        System.out.println(instance1 == instance2);
    }
}
